﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Admin/Admin.Master" AutoEventWireup="true" CodeBehind="UserRoleManager.aspx.cs" Inherits="Hengbei.Web.Admin.UserRoleManager" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <asp:EntityDataSource ID="edsUsers" runat="server" 
        ConnectionString="name=HengbeiEntities" DefaultContainerName="HengbeiEntities" 
        EnableDelete="True" EnableFlattening="False" EnableInsert="True" 
        EnableUpdate="True" EntitySetName="SiteUsers" EntityTypeFilter="SiteUser">
    </asp:EntityDataSource>
    <asp:EntityDataSource ID="edsRoles" runat="server" 
        ConnectionString="name=HengbeiEntities" DefaultContainerName="HengbeiEntities" 
        EnableDelete="False" EnableFlattening="False" EnableInsert="False" 
        EnableUpdate="False" EntitySetName="UserRoles" EntityTypeFilter="UserRole">
    </asp:EntityDataSource>
    <asp:EntityDataSource ID="edsUserRoles" runat="server" 
        ConnectionString="name=HengbeiEntities" DefaultContainerName="HengbeiEntities" 
        EnableDelete="True" EnableFlattening="False" EnableInsert="True" 
        EnableUpdate="True" EntitySetName="UserInRoles" 
        EntityTypeFilter="UserInRole" Include="SiteUser,UserRole">
    </asp:EntityDataSource>
    <asp:ScriptManager ID="smUserRole" runat="server">
    </asp:ScriptManager>
    <div style="text-align: center;">
        <h3>
            用户角色管理</h3>
    </div>
    <br />
    <br />
    <br />
    <br />
    <asp:Label ID="lblManage" runat="server" CssClass="Label" Text="管理已有用户："></asp:Label>
    <br />
    <asp:UpdatePanel ID="upUserRoles" runat="server">
        <ContentTemplate>
            <asp:GridView ID="gvUserRoles" runat="server" AllowPaging="True" 
                AllowSorting="True" AutoGenerateColumns="False" CellPadding="4" 
                DataKeyNames="ID" DataSourceID="edsUserRoles" ForeColor="#333333" 
                GridLines="None" onrowdatabound="gvUserRoles_RowDataBound" Width="100%" 
                onrowupdating="gvUserRoles_RowUpdating">
                <AlternatingRowStyle BackColor="White" ForeColor="#284775" />
                <Columns>
                    <asp:CommandField ShowDeleteButton="True" ShowEditButton="True" />
                    <asp:BoundField DataField="ID" HeaderText="ID" ReadOnly="True" 
                        SortExpression="ID" Visible="False" />
                    <asp:TemplateField HeaderText="UserID" SortExpression="UserID">
                        <ItemTemplate>
                            <asp:Label ID="Label1" runat="server" Text='<%# Eval("SiteUser.Name") %>'></asp:Label>
                        </ItemTemplate>
                        <EditItemTemplate>
                            <asp:DropdownList ID="ddlUser" runat="server" DataSourceID="edsUsers" 
                                DataTextField="Name" DataValueField="ID" SelectedValue='<%# Bind("UserID") %>' ></asp:DropdownList>
                        </EditItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="RoleID" SortExpression="RoleID">
                        <ItemTemplate>
                            <asp:Label ID="Label2" runat="server" Text='<%# Eval("UserRole.RoleName") %>'></asp:Label>
                        </ItemTemplate>
                        <EditItemTemplate>
                            <asp:DropdownList ID="ddlRole" runat="server" DataSourceID="edsRoles" 
                                DataTextField="RoleName" DataValueField="ID" SelectedValue='<%# Bind("RoleID") %>' ></asp:DropdownList>
                        </EditItemTemplate>
                    </asp:TemplateField>
                </Columns>
                <EditRowStyle BackColor="#999999" />
                <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
                <RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
                <SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
                <SortedAscendingCellStyle BackColor="#E9E7E2" />
                <SortedAscendingHeaderStyle BackColor="#506C8C" />
                <SortedDescendingCellStyle BackColor="#FFFDF8" />
                <SortedDescendingHeaderStyle BackColor="#6F8DAE" />
            </asp:GridView>
        </ContentTemplate>
    </asp:UpdatePanel>
</asp:Content>
